package server.business.converter;

import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.CellData;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.property.ExcelContentProperty;
import org.springframework.stereotype.Component;

/**
 * @Author: 赵越
 * @Description: 退血驳回原因数据字典转换
 * @CreateTime: 2023-04-13  19:42
 */
@Component
public class BackRejectReasonConverter implements Converter<String> {
    @Override
    public Class<String> supportJavaTypeKey() {
        return String.class;
    }

    @Override
    public CellDataTypeEnum supportExcelTypeKey() {
        return CellDataTypeEnum.STRING;
    }

    @Override
    public String convertToJavaData(CellData arg0, ExcelContentProperty arg1, GlobalConfiguration arg2)
            throws Exception {
        throw new UnsupportedOperationException("Unimplemented method 'convertToJavaData'");
    }

    @Override
    public CellData<String> convertToExcelData(String value, ExcelContentProperty excelContentProperty, GlobalConfiguration globalConfiguration) throws Exception {
        if (value == null) {
            return new CellData<>("");
        } else if (value.equals("00")) {
            return new CellData<>("已用");
        } else if (value.equals("01")) {
            return new CellData<>("包装损坏");
        } else if (value.equals("02")) {
            return new CellData<>("血标本凝固");
        } else if (value.equals("03")) {
            return new CellData<>("血标本量不准");
        } else if (value.equals("04")) {
            return new CellData<>("血标本溶血");
        } else {
            return new CellData<>("错误数据");
        }
    }
}
